﻿namespace Web7.Caching
{
    /// <summary>
    /// 缓存管理接口
    /// </summary>
    public interface ICacheManager
    {
        /// <summary>
        /// runtime 缓存
        /// </summary>
        AbstractCacheProvider GenerationScopedCache { get; set; }

        /// <summary>
        /// 字典缓存
        /// </summary>
        AbstractCacheProvider BatchScopedCache { get; set; }
    }
    /// <summary>
    /// 缓存管理类(单例)
    /// </summary>
    public class CacheManager : ICacheManager
    {
        private static CacheManager _instance;
        protected CacheManager()
        {
            BatchScopedCache = new DictionaryCacheProvider();
            GenerationScopedCache = new RuntimeCacheProvider();
        }
        public static CacheManager Instance()
        {
            return _instance ?? (_instance = new CacheManager());
        }

        public AbstractCacheProvider GenerationScopedCache { get; set; }

        public AbstractCacheProvider BatchScopedCache{ get; set; }
    }
}
